import { Entity, Column, OneToMany, Index, CreateDateColumn, UpdateDateColumn } from 'typeorm';
import { BaseEntity } from '../../common/entity/base.entity';
// import { JobDistributionAgent } from '../job-distribution-agent/entities/job-distribution-agent.entity';

@Entity('agents')
@Index(['walletAddress'])
@Index(['agentClassification'])
@Index(['isActive'])
export class Agent extends BaseEntity {
  @Column()
  agentName: string;

  @Column()
  agentAddress: string;

  @Column('text')
  description: string;

  @Column('text')
  authorBio: string;

  @Column()
  agentClassification: string;

  @Column('text', { array: true, default: [] })
  tags: string[];

  @Column({ default: true })
  isPrivate: boolean;

  @Column({ default: true })
  autoAcceptJobs: boolean;

  @Column({ default: 'result' })
  contractType: string;

  @Column({ default: true })
  isActive: boolean;

  @Column('decimal', { precision: 3, scale: 1, default: 0.0 })
  reputation: number;

  @Column('decimal', { precision: 3, scale: 2, default: 0.0 })
  successRate: number;

  @Column({ default: 0 })
  totalJobsCompleted: number;

  @Column()
  @Index()
  walletAddress: string;

  // 明确重写时间戳字段，确保数据库默认值
  @CreateDateColumn({ name: 'createdAt', default: () => 'CURRENT_TIMESTAMP' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updatedAt', default: () => 'CURRENT_TIMESTAMP' })
  updatedAt: Date;

//   @OneToMany(() => JobDistributionAgent, (jobDistribution) => jobDistribution.agent)
//   jobDistributions: JobDistributionAgent[];
}